﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Net
{
    public class MailClient
    {
        public Task<bool> SendAsync(MailMessage message)
        {
            TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>();
            SmtpClient client = new SmtpClient();
            client.SendCompleted += (sender, e) =>
            {
                taskCompletionSource.SetResult(e.Error == null && !e.Cancelled);
            };
            client.SendAsync(message, null);
            return taskCompletionSource.Task;
        }
    }
}
